
;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
; DATA
;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
align 4
d4posrout       dd      p40r0a,p40r0b

d4posrouttbl0   dd      p40r0a,p40r1a,p40r2a,p40r3a,p40r0a,p40r1a,p40r2a,p40r3a
d4posrouttbl1   dd      p40r0b,p40r1b,p40r2b,p40r3b,p40r2b,p40r3b,p40r0b,p40r1b

d4wingframe     dd      cspr0b,cspr0c,cspr0d,cspr0c
d4centercspr    dd      cspr0a

d4centercsprtbl dd      cspr0a,cspr17,cspr11,cspr10,cspr22

d4loc           dw      0

d4frame         db      0,2
d4posroutindex  db      0
d4centercspri   db      0

;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
; CODE
;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±

;ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
p40:
        xor esi,esi
        call p40r4
        inc esi
        call p40r4
        jnc _ret
        movzx ebx,d4posroutindex
        inc ebx
        and bl,7
        mov d4posroutindex,bl
        mov eax,d4posrouttbl0[ebx*4]
        mov d4posrout[0],eax
        mov eax,d4posrouttbl1[ebx*4]
        mov d4posrout[4],eax
        mov d4loc,0
        movzx ebx,d4centercspri
        inc bl
        cmp bl,5
        jb short p40f0
        xor bl,bl
p40f0:
        mov d4centercspri,bl
        mov eax,d4centercsprtbl[ebx*4]
        mov d4centercspr,eax
        jmp setnext
;-----------------------------------------------------------------------------
p40r4:
        call d4posrout[esi*4]
        pushfd
        imul ebp,edx,100
        add ebp,_vidptr
        mov eax,ebx
        shr ebx,2
        lea ebp,[ebp+ebx-100*26-18]
        and eax,3
        mov ah,vidbittbl2[eax]
        movzx ebx,d4frame[esi]
        inc ebx
        and bl,3
        mov d4frame[esi],bl
        mov dx,3c5h
        mov edi,ebp
        mov al,ah
        call d4wingframe[ebx*4]
        rol ah,1
        adc ebp,100*9+6
        mov edi,ebp
        mov al,ah
        call d4centercspr
        popfd
        ret
;-----------------------------------------------------------------------------
p40r0a:
        movzx edx,d4loc
        add edx,2
        mov d4loc,dx
        sub edx,50
        jnc short p40r0af0
p40r0af1:
        xor edx,edx
        xor ebx,ebx
        clc
        ret
p40r0af0:
        mov eax,offset sincos0
        mov al,dl
        movzx ebx,byte ptr [eax]
        shr ebx,1
        add ebx,131
        ret
;-----------------------------------------------------------------------------
p40r0b:
        movzx edx,d4loc
        cmp dx,276
        je short p40r0bf0
        cmp dx,226
        jae p40r0af1
        mov eax,offset sincos0
        mov al,dl
        sub al,50+80h
        movzx ebx,byte ptr [eax]
        shr ebx,1
        add ebx,131
        clc
        ret
p40r0bf0:
        xor edx,edx
        xor ebx,ebx
        stc
        ret
;-----------------------------------------------------------------------------
p40r1a:
        movzx ebx,d4loc
        add ebx,3
        mov d4loc,bx
        sub ebx,80
        jc p40r0af1
        mov eax,offset sincos0
        mov al,bl
        movzx edx,byte ptr [eax]
        shr edx,1
        add edx,49
        ret
;-----------------------------------------------------------------------------
p40r1b:
        movzx ebx,d4loc
        cmp bx,472
        jae p40r0bf0
        cmp bx,392
        jae p40r0af1
        mov eax,offset sincos0
        mov al,bl
        sub al,80+80h
        movzx edx,byte ptr [eax]
        shr edx,1
        add edx,49
        clc
        ret
;-----------------------------------------------------------------------------
p40r2a:
        movzx edx,d4loc
        add edx,2
        mov d4loc,dx
        sub dx,50
        jc p40r0af1
        mov eax,offset sincos0
        mov al,dl
        movzx ebx,byte ptr [eax]
        shr ebx,1
        add ebx,131
        sub dl,226
        neg dl
        ret
;-----------------------------------------------------------------------------
p40r2b:
        movzx edx,d4loc
        cmp dx,276
        je p40r0bf0
        cmp dx,226
        jae p40r0af1
        mov eax,offset sincos0
        mov al,dl
        sub al,50+80h
        movzx ebx,byte ptr [eax]
        shr ebx,1
        add ebx,131
        sub dl,224
        neg dl
        clc
        ret
;-----------------------------------------------------------------------------
p40r3a:
        movzx ebx,d4loc
        add ebx,3
        mov d4loc,bx
        sub ebx,78
        jc p40r0af1
        mov eax,offset sincos0
        mov al,bl
        movzx edx,byte ptr [eax]
        shr edx,1
        add edx,49
        sub ebx,396
        neg ebx
        ret
;-----------------------------------------------------------------------------
p40r3b:
        movzx ebx,d4loc
        cmp bx,474
        jae p40r0bf0
        cmp bx,396
        jae p40r0af1
        mov eax,offset sincos0
        mov al,bl
        sub al,78+80h
        movzx edx,byte ptr [eax]
        shr edx,1
        add edx,49
        sub ebx,393
        neg ebx
        clc
        ret

